home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wlist.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  100 lines

  1. ; $Id: wlist.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple list widget.
  7. ; In this example, a list of eleven items numbered
  8. ; zero through ten appears.  When a list item is selected, 
  9. ; that item's name is printed in the IDL window.
  10.  
  11. ; The items in a list widget can be selected only one at 
  12. ; a time.  In this sense, list widgets are similar to 
  13. ; exclusive menus.  Lists, however, can be made to display
  14. ; only a few items at a time and scroll to show the rest
  15. ; of the items in the list.
  16.  
  17.  
  18.  
  19. PRO wlist_event, event
  20. ; This procedure is the event handler for a simple list widget.
  21.  
  22. ; This COMMON block is used because both 'wlist' and 'wlist_event' 
  23. ; should know about any widget that can be touched: 
  24.  
  25. COMMON wlistblock, list
  26.  
  27. ; Put the User Value of any widget touched into the variable 'eventval':
  28.  
  29. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  30.  
  31. ; This CASE statement branches based upon the value of 'eventval':
  32.  
  33. CASE eventval OF
  34.     "LIST"    : BEGIN
  35.           ; The list has been touched.
  36.           ; The index of the list item touched is held in
  37.           ; 'event.index'... how convenient!
  38.  
  39.           ; Put the value of 'event.index' into the variable
  40.           ; 'selection':
  41.           selection = event.index
  42.  
  43.           ; Print the index of the item selected in the
  44.           ; IDL window:
  45.           PRINT, 'List item ' + STRING(selection) + ' selected.'
  46.           END
  47. ENDCASE
  48. END
  49.  
  50.  
  51. PRO wlist, GROUP = GROUP
  52. ; This procedure creates a simple list widget.
  53.  
  54. ; This COMMON block is used because both 'wlist' and 'wlist_event' 
  55. ; should know about any widget that can be touched:
  56.  
  57. COMMON wlistblock, list
  58.  
  59. ; Make the top-level base. The XSIZE keyword is used to make
  60. ; the base wide enough so that the full title shows:
  61.  
  62. base = WIDGET_BASE(TITLE = 'Example List Widget', /COLUMN, XSIZE = 300)
  63.  
  64. ; Make an array that holds the text of the list items:
  65.  
  66. listitems = [    'Item Zero', $
  67.         'Item One', $
  68.         'Item Two', $
  69.         'Item Three', $
  70.         'Item Four', $
  71.         'Item Five', $
  72.         'Item Six', $
  73.         'Item Seven', $
  74.         'Item Eight', $
  75.         'Item Nine', $
  76.         'Item Ten']
  77.  
  78. ; Make the list widget. The YSIZE keyword controls how many list items
  79. ; will be visible at a time:
  80.  
  81. list = WIDGET_LIST(base, $        ; This list belongs to 'base'.
  82.            VALUE = listitems, $    ; Put 'listitems' in the list.
  83.            UVALUE = 'LIST', $    ; 'LIST' is this widgets User Value.
  84.            YSIZE = 5)        ; Show five items at a time.
  85.  
  86. ; Realize the widgets:
  87. WIDGET_CONTROL, base, /REALIZE
  88.  
  89. ; Hand off to the XMANAGER:
  90. XMANAGER, 'wlist', base, GROUP_LEADER = GROUP, /NO_BLOCK
  91.  
  92. END
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.